#include <mach_wakecpu.h>
#include <smpboot_hooks.h>
+#include <asm-xen/evtchn.h>
+
/* Set if we find a B stepping CPU */
static int __initdata smp_b_stepping;
int cpu = smp_processor_id();
per_cpu(resched_irq, cpu) =
- bind_ipi_on_cpu_to_irq(RESCHEDULE_VECTOR);
+ bind_ipi_to_irq(RESCHEDULE_VECTOR);
sprintf(resched_name[cpu], "resched%d", cpu);
BUG_ON(request_irq(per_cpu(resched_irq, cpu), smp_reschedule_interrupt,
SA_INTERRUPT, resched_name[cpu], NULL));
per_cpu(callfunc_irq, cpu) =
- bind_ipi_on_cpu_to_irq(CALL_FUNCTION_VECTOR);
+ bind_ipi_to_irq(CALL_FUNCTION_VECTOR);
sprintf(callfunc_name[cpu], "callfunc%d", cpu);
BUG_ON(request_irq(per_cpu(callfunc_irq, cpu),
smp_call_function_interrupt,
#include "io_ports.h"
+#include <asm-xen/evtchn.h>
+
extern spinlock_t i8259A_lock;
int pit_latch_buggy; /* extern */
if ( HYPERVISOR_event_channel_op(&op) != 0 )
panic("Failed to unbind virtual IRQ %d\n", virq);
- /* This is a slight hack. Interdomain ports can be allocated
- directly by userspace, and at that point they get bound by
- Xen to vcpu 0. We therefore need to make sure that if we
- get an event on an event channel we don't know about vcpu 0
- handles it. Binding channels to vcpu 0 when closing them
- achieves this. */
+ /*
+ * This is a slight hack. Interdomain ports can be allocated directly
+ * by userspace, and at that point they get bound by Xen to vcpu 0. We
+ * therefore need to make sure that if we get an event on an event
+ * channel we don't know about vcpu 0 handles it. Binding channels to
+ * vcpu 0 when closing them achieves this.
+ */
bind_evtchn_to_cpu(evtchn, 0);
evtchn_to_irq[evtchn] = -1;
irq_to_evtchn[irq] = -1;
spin_unlock(&irq_mapping_update_lock);
}
-int bind_ipi_on_cpu_to_irq(int ipi)
+int bind_ipi_to_irq(int ipi)
{
evtchn_op_t op;
int evtchn, irq;
spin_unlock(&irq_mapping_update_lock);
}
-int bind_evtchn_to_irq(int evtchn)
+int bind_evtchn_to_irq(unsigned int evtchn)
{
int irq;
return irq;
}
-void unbind_evtchn_from_irq(int evtchn)
+void unbind_evtchn_from_irq(unsigned int evtchn)
{
int irq = evtchn_to_irq[evtchn];
spin_unlock(&irq_mapping_update_lock);
}
+int bind_evtchn_to_irqhandler(
+ unsigned int evtchn,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id)
+{
+ unsigned int irq;
+ int retval;
+
+ BUG_ON((irqflags & ~SA_SAMPLE_RANDOM) != 0);
+
+ irq = bind_evtchn_to_irq(evtchn);
+ retval = request_irq(irq, handler, irqflags, devname, dev_id);
+ if ( retval != 0 )
+ unbind_evtchn_from_irq(evtchn);
+
+ return retval;
+}
+
+void unbind_evtchn_from_irqhandler(unsigned int evtchn, void *dev_id)
+{
+ unsigned int irq = evtchn_to_irq[evtchn];
+ free_irq(irq, dev_id);
+ unbind_evtchn_from_irq(evtchn);
+}
+
static void do_nothing_function(void *ign)
{
}
return;
}
- /* Tell Xen to send future instances of this interrupt to the
- other vcpu */
+ /* Tell Xen to send future instances of this interrupt to other vcpu. */
op.cmd = EVTCHNOP_bind_vcpu;
op.u.bind_vcpu.port = evtchn;
op.u.bind_vcpu.vcpu = tcpu;
- /* If this fails, it usually just indicates that we're dealing
- with a virq or IPI channel, which don't actually need to be
- rebound. Ignore it, but don't do the xenlinux-level rebind
- in that case. */
+ /*
+ * If this fails, it usually just indicates that we're dealing with a virq
+ * or IPI channel, which don't actually need to be rebound. Ignore it,
+ * but don't do the xenlinux-level rebind in that case.
+ */
if (HYPERVISOR_event_channel_op(&op) >= 0)
bind_evtchn_to_cpu(evtchn, tcpu);
spin_unlock(&irq_mapping_update_lock);
- /* Now send the new target processor a NOP IPI. When this
- returns, it will check for any pending interrupts, and so
- service any that got delivered to the wrong processor by
- mistake. */
- /* XXX: The only time this is called with interrupts disabled is
- from the hotplug/hotunplug path. In that case, all cpus are
- stopped with interrupts disabled, and the missed interrupts
- will be picked up when they start again. This is kind of a
- hack.
- */
- if (!irqs_disabled()) {
+ /*
+ * Now send the new target processor a NOP IPI. When this returns, it
+ * will check for any pending interrupts, and so service any that got
+ * delivered to the wrong processor by mistake.
+ *
+ * XXX: The only time this is called with interrupts disabled is from the
+ * hotplug/hotunplug path. In that case, all cpus are stopped with
+ * interrupts disabled, and the missed interrupts will be picked up when
+ * they start again. This is kind of a hack.
+ */
+ if (!irqs_disabled())
smp_call_function(do_nothing_function, NULL, 0, 0);
- }
}
#include <asm/irq.h>
#include <asm/mmu_context.h>
#include <asm-xen/ctrl_if.h>
+#include <asm-xen/evtchn.h>
#include <asm-xen/hypervisor.h>
#include <asm-xen/xen-public/dom0_ops.h>
#include <asm-xen/linux-public/suspend.h>
*/
#include "common.h"
-#include <asm-xen/evtchn.h>
#ifdef CONFIG_XEN_BLKDEV_GRANT
#include <asm-xen/xen-public/grant_table.h>
#endif
#include <asm/setup.h>
#include <asm/pgalloc.h>
#include <asm-xen/ctrl_if.h>
+#include <asm-xen/evtchn.h>
#include <asm-xen/hypervisor.h>
#include <asm-xen/xen-public/io/blkif.h>
#include <asm-xen/xen-public/io/ring.h>
/* Physical parameters of the comms window. */
unsigned long shmem_frame;
unsigned int evtchn;
- int irq;
/* Comms information. */
blkif_back_ring_t blk_ring;
/* VBDs attached to this interface. */
* may be outstanding requests at the disc whose asynchronous responses
* must still be notified to the remote driver.
*/
- unbind_evtchn_from_irq(blkif->evtchn);
+ unbind_evtchn_from_irqhandler(blkif->evtchn, blkif);
#ifdef CONFIG_XEN_BLKDEV_GRANT
{
BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
blkif->evtchn = evtchn;
- blkif->irq = bind_evtchn_to_irq(evtchn);
blkif->shmem_frame = shmem_frame;
blkif->status = CONNECTED;
blkif_get(blkif);
- request_irq(blkif->irq, blkif_be_int, 0, "blkif-backend", blkif);
+ bind_evtchn_to_irqhandler(
+ blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
connect->status = BLKIF_BE_STATUS_OKAY;
}
blkif->status = DISCONNECTING;
blkif->disconnect_rspid = rsp_id;
wmb(); /* Let other CPUs see the status change. */
- free_irq(blkif->irq, blkif);
blkif_deschedule(blkif);
blkif_put(blkif);
return 0; /* Caller should not send response message. */
static int blkif_handle = 0;
static unsigned int blkif_state = BLKIF_STATE_CLOSED;
static unsigned int blkif_evtchn = 0;
-static unsigned int blkif_irq = 0;
static int blkif_control_rsp_valid;
static blkif_response_t blkif_control_rsp;
free_page((unsigned long)blk_ring.sring);
blk_ring.sring = NULL;
}
- free_irq(blkif_irq, NULL);
- blkif_irq = 0;
-
- unbind_evtchn_from_irq(blkif_evtchn);
+ unbind_evtchn_from_irqhandler(blkif_evtchn, NULL);
blkif_evtchn = 0;
}
int err = 0;
blkif_evtchn = status->evtchn;
- blkif_irq = bind_evtchn_to_irq(blkif_evtchn);
- err = request_irq(blkif_irq, blkif_int, SA_SAMPLE_RANDOM, "blkif", NULL);
- if ( err )
+ err = bind_evtchn_to_irqhandler(
+ blkif_evtchn, blkif_int, SA_SAMPLE_RANDOM, "blkif", NULL);
+ if ( err != 0 )
{
- WPRINTK("request_irq failed (err=%d)\n", err);
+ WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err);
return;
}
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <asm-xen/ctrl_if.h>
+#include <asm-xen/evtchn.h>
#include <asm-xen/xen-public/io/netif.h>
#include <asm/io.h>
#include <asm/pgalloc.h>
#include "common.h"
#include <asm-xen/balloon.h>
-#include <asm-xen/evtchn.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#include <linux/delay.h>
#define dynirq_to_irq(_x) ((_x) + DYNIRQ_BASE)
#define irq_to_dynirq(_x) ((_x) - DYNIRQ_BASE)
-#ifndef __ASSEMBLY__
-/* Dynamic binding of event channels and VIRQ sources to Linux IRQ space. */
-extern int bind_virq_to_irq(int virq);
-extern void unbind_virq_from_irq(int virq);
-extern int bind_ipi_to_irq(int ipi);
-extern int bind_ipi_on_cpu_to_irq(int ipi);
-extern void unbind_ipi_from_irq(int ipi);
-extern int bind_evtchn_to_irq(int evtchn);
-extern void unbind_evtchn_from_irq(int evtchn);
-
-extern void irq_suspend(void);
-extern void irq_resume(void);
-#endif /* __ASSEMBLY__ */
-
#endif /* _ASM_IRQ_VECTORS_H */
#define dynirq_to_irq(_x) ((_x) + DYNIRQ_BASE)
#define irq_to_dynirq(_x) ((_x) - DYNIRQ_BASE)
-#ifndef __ASSEMBLY__
-/* Dynamic binding of event channels and VIRQ sources to Linux IRQ space. */
-extern int bind_virq_to_irq(int virq);
-extern void unbind_virq_from_irq(int virq);
-extern int bind_ipi_to_irq(int ipi);
-extern int bind_ipi_on_cpu_to_irq(int ipi);
-extern void unbind_ipi_from_irq(int ipi);
-extern int bind_evtchn_to_irq(int evtchn);
-extern void unbind_evtchn_from_irq(int evtchn);
-
-extern void irq_suspend(void);
-extern void irq_resume(void);
-#endif /* __ASSEMBLY__ */
-
#endif /* _ASM_IRQ_VECTORS_H */
#define __ASM_EVTCHN_H__
#include <linux/config.h>
+#include <linux/interrupt.h>
#include <asm-xen/hypervisor.h>
#include <asm/ptrace.h>
#include <asm-xen/synch_bitops.h>
* LOW-LEVEL DEFINITIONS
*/
+/* Dynamically bind a VIRQ source to Linux IRQ space. */
+extern int bind_virq_to_irq(int virq);
+extern void unbind_virq_from_irq(int virq);
+
+/* Dynamically bind an IPI source to Linux IRQ space. */
+extern int bind_ipi_to_irq(int ipi);
+extern void unbind_ipi_from_irq(int ipi);
+
+/* Dynamically bind an event-channel port to Linux IRQ space. */
+extern int bind_evtchn_to_irq(unsigned int evtchn);
+extern void unbind_evtchn_from_irq(unsigned int evtchn);
+
+/*
+ * Dynamically bind an event-channel port to an IRQ-like callback handler.
+ * On some platforms this may not be implemented via the Linux IRQ subsystem.
+ * You *cannot* trust the irq argument passed to the callback handler.
+ */
+extern int bind_evtchn_to_irqhandler(
+ unsigned int evtchn,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id);
+extern void unbind_evtchn_from_irqhandler(unsigned int evtchn, void *dev_id);
+
+extern void irq_suspend(void);
+extern void irq_resume(void);
+
/* Entry point for notifications into Linux subsystems. */
asmlinkage void evtchn_do_upcall(struct pt_regs *regs);